package hlhj.fhp.checkpoint.adp

import android.content.Intent
import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.mymvp.log
import hlhj.fhp.checkpoint.R
import hlhj.fhp.checkpoint.atys.OrderAty
import hlhj.fhp.checkpoint.fgms.OrderListFgm
import hlhj.fhp.checkpoint.javaBean.ViolationOrderBean
import hlhj.fhp.checkpoint.javaBean.YearOrderBean
import hlhj.fhp.checkpoint.utils.TimeUtil

/**
 * Created by Never Fear   on 2018\11\12 0012.
Never More....
 */
class YearOrderListAdp(private val datas:ArrayList<YearOrderBean.InfoBean.ListBean.DataBean>)
    :BaseQuickAdapter<YearOrderBean.InfoBean.ListBean.DataBean,BaseViewHolder>(R.layout.all_order_item,datas) {
    override fun convert(helper: BaseViewHolder?, item: YearOrderBean.InfoBean.ListBean.DataBean?) {
        helper?.setText(R.id.itemTag,item?.plate_number)
        helper?.setText(R.id.itemPrice,item?.original_price)
        helper?.setText(R.id.itemNum,"订单编号：${item?.order_number}")
        helper?.setText(R.id.itemTime,"下单时间：${item?.create_time}")

        when(item?.status){
            0->{
                helper?.setText(R.id.itemStatus,"待支付")
                helper?.setText(R.id.tvOffer,"加服务费${item?.offer}元")

                val nowTimeStamp    = System.currentTimeMillis()
                val createTimeStamp = TimeUtil.dateToStamp(item?.create_time)
//        val eTime           =
                val alreadySec = (nowTimeStamp - createTimeStamp.toLong()) / 1000
                val leftSec=24*60*60-alreadySec
                val s = leftSec%60
                val min=leftSec/60%60
                val hour=leftSec/60/60
                if (leftSec<=0){
                    helper?.setVisible(R.id.timeLeft,false)

                }else{
                    helper?.setVisible(R.id.timeLeft,true)

                    helper?.setText(R.id.timeLeft,"剩余时间${hour}:${min}:${s}")

                }
                helper?.setVisible(R.id.loPay,true)

            }
            1->{
                helper?.setText(R.id.itemStatus,"已撤销")
                helper?.setVisible(R.id.timeLeft,false)
                helper?.setVisible(R.id.loPay,false)
            }
            2->{
                helper?.setText(R.id.itemStatus,"处理中")
                helper?.setVisible(R.id.timeLeft,false)
                helper?.setVisible(R.id.loPay,false)
            }
            3->{
                helper?.setText(R.id.itemStatus,"已完成")
                helper?.setVisible(R.id.timeLeft,false)
                helper?.setVisible(R.id.loPay,false)
            }
        }
    }

}